package com.hanyee.percentProcess;

import java.util.ArrayList;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;

import com.hanyee.percentProcess.widget.PercentProcessWidgetView;
import com.hanyee.percentProcess.widget.PercentProgressView;
import com.hanyee.percentProcess.widget.PercentProgressView.Category;
import com.hanyee.percentprocesswidget.R;

public class PercentProcessWidgetActivity extends Activity {

	PercentProcessWidgetView mPercentView;
	PercentProgressView mProgressView;
	ArrayList<String> data;
	private ArrayList<Category> mCategories;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		mPercentView = (PercentProcessWidgetView) findViewById(R.id.percentWidget);
		mProgressView = (PercentProgressView) findViewById(R.id.percent2);
		data = new ArrayList<String>();
		data.add(Color.BLUE + "|0.27");
		data.add(Color.RED + "|0.35");
		data.add(Color.YELLOW + "|0.10");
		data.add(Color.BLACK + "|0.28");
		mCategories = new ArrayList<PercentProgressView.Category>();
		mCategories.add(mProgressView.new Category(Color.BLUE, 0.27f));
		mCategories.add(mProgressView.new Category(Color.RED, 0.35f));
		mCategories.add(mProgressView.new Category(Color.YELLOW, 0.10f));
		mCategories.add(mProgressView.new Category(Color.BLACK, 0.28f));

		findViewById(R.id.beginDraw).setOnClickListener(
				new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						mPercentView.parseDataAndPerform(data);
						mProgressView.setPercent(mCategories);
					}
				});

	}

}
